const QiniuManager = require('./src/utils/QiniuManager');
var accessKey = 'w6wDjMDNZhiy3oXg9ZMc9AsX9piZM5lr4-gEs65z';
var secretKey = 'XB9LjpSD4MUX1K-Cz_eLQVBjE7S0X5CwXkEbvEeJ';
const path = require('path')
const manager = new QiniuManager(accessKey, secretKey , 'mmcat')
// manager.getBucketDomain().then((data) => {
//   console.log(data)
// })
// manager.generateDownloadLink('前端优化.docx').then(data => {
//   console.log(data)
// })
// manager.downLoadFile('前端优化.docx', path.join(__dirname, '前端优化.docx'))
// var mac = new qiniu.auth.digest.Mac(accessKey, secretKey);
// var options = {
//     scope: 'mmcat',
// };
// var putPolicy = new qiniu.rs.PutPolicy(options);
// var uploadToken=putPolicy.uploadToken(mac);

// var config = new qiniu.conf.Config();
// // 空间对应的机房
// config.zone = qiniu.zone.Zone_z0;
// const path = require('path')
// // console.log(path.join('C:/Users/USER/Desktop', '前端优化.docx'))
// var localFile = path.join('C:/Users/USER/Desktop', '前端优化.docx');
// var formUploader = new qiniu.form_up.FormUploader(config);
// var putExtra = new qiniu.form_up.PutExtra();
// var key='前端优化.docx';
// // 文件上传
// formUploader.putFile(uploadToken, key, localFile, putExtra, function(respErr,
//   respBody, respInfo) {
//   if (respErr) {
//     throw respErr;
//   }
//   if (respInfo.statusCode == 200) {
//     console.log(respBody);
//   } else {
//     console.log(respInfo.statusCode);
//     console.log(respBody);
//   }
// });

// var bucketManager = new qiniu.rs.BucketManager(mac, config);
// var publicBucketDomain = 'http://qn9rs30n2.hd-bkt.clouddn.com';
// var publicDownloadUrl = bucketManager.publicDownloadUrl(publicBucketDomain, key);
// console.log(publicDownloadUrl);